package com.cskaoyan;


import com.cskaoyan.utils.DBCPUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2022/07/27 11:42
 *
 * @author ciggar
 */
public class Demo {

    public static void main(String[] args) throws SQLException {

        Connection connection = DBCPUtils.getConnection();


        // 创建Statement对象
        Statement statement = connection.createStatement();

        // 发送SQL语句
        ResultSet resultSet = statement.executeQuery("select * from account");

        // 解析结果集
        while (resultSet.next()) {
            int id = resultSet.getInt("id");
            String name = resultSet.getString("name");
            int money = resultSet.getInt("money");
            System.out.println("id:" + id + ", name:" + name  + ", money:" + money);
        }

        // 关闭资源
        resultSet.close();
        statement.close();

        connection.close();

    }
}
